
const state = {
    isCollapse: false, // 是否折叠
    selectMenus: [], // 选中的menu
}

const mutations = {
    changeCollapse(state) {
        state.isCollapse = !state.isCollapse
    },
    addRoute(state, item) {
        // 去重
        if (state.selectMenus.findIndex(menu => menu.path === item.path) === -1) {
            state.selectMenus.push(item)
        }
    },
    removeSelectMenu(state, item) {
        // 找到点击数据的索引
        const idx = state.selectMenus.findIndex(menu => menu.path === item.path)
        // 通过索引删除数据
        state.selectMenus.splice(idx, 1)
    },
}

export default {
    state,
    mutations
}